/*
 * @lc app=leetcode.cn id=1700 lang=javascript
 *
 * [1700] 无法吃午餐的学生数量
 */

// @lc code=start
/**
 * @param {number[]} students
 * @param {number[]} sandwiches
 * @return {number}
 */
 var countStudents = function (students, sandwiches) {
    // 因为 [].indexOf('any paramter') = -1
    // 所以这里不需要判断 students 是否为空
    while (sandwiches.length && students.indexOf(sandwiches[0]) !== -1) {
      const student = students.shift();

      student !== sandwiches[0] ? students.push(student) : sandwiches.shift();
    }
    return students.length;
  };
  // @lc code=end
